/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SStoreConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.user.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.user.AContracts;
import com.thor.palmmall.rest.user.AStore;
import com.thor.palmmall.spi.user.SContracts;
import com.thor.palmmall.spi.user.SStore;

/**
 * @author wolv
 *
 */
public class AStoreConverter implements Converter<SStore, AStore> {

  public static AStoreConverter getInstance() {
    if (instance == null)
      instance = new AStoreConverter();
    return instance;
  }

  private static AStoreConverter instance;

  private AStoreConverter() {
  }

  @Override
  public AStore convert(SStore source) {
    if (source == null)
      return null;

    AStore target = new AStore();
    target.setCode(source.getCode());
    target.setContracts(ConverterUtil.convert(source.getContracts(), AContractsConverter.getInstance()));
    target.setName(source.getName());
    target.setUuid(source.getUuid());
    target.setUpperRegion(UCN.newInstance(source.getUpperRegion()));
    return target;
  }

}
